package com.czk.utils;

import com.czk.service.HospitalSetService;
import com.czk.yygh.common.helper.HttpRequestHelper;
import com.czk.yygh.common.utls.MD5;

import java.util.Map;
import java.util.Objects;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/11/11 21:07
 */
public class ApiUtil {
    private ApiUtil() {

    }

    public static Map<String, Object> transferMap(Map<String, String[]> map) {
        // 转为map
        Map<String, Object> paramMap = HttpRequestHelper.switchMap(map);
        return paramMap;
    }

    public static boolean checkSign(HospitalSetService hospitalSetService, Map<String, Object> paramMap) {
        // 医院系统传过来的签名
        String sign = (String) paramMap.get("sign");
        // 根据医院传过来的数据编号查询签名
        String hoscode = (String) paramMap.get("hoscode");
        String resultHoscode = hospitalSetService.getSignKey(hoscode);

        // 把数据库查询出来的进行md5加密
        String encrypt = MD5.encrypt(resultHoscode);
        return Objects.equals(encrypt,sign);
    }
}
